﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


/// <summary>
/// 表示用户实体。
/// </summary>
public class User
{
    private string _Username; // NOT NULL
    private string _Password; // NOT NULL


    /// <summary>
    /// 使用指定的用户名和密码实例化一个新的用户类型对象。
    /// </summary>
    /// <param name="username">指定的用户名。</param>
    /// <param name="password">指定的密码。</param>
    /// <exception cref="System.ArgumentNullException">当用户名或密码为空时抛出该异常。</exception>
    /// <exception cref="System.ArgumentOutOfRangeException">当用户名的长度超过 128 个字符时抛出该异常。</exception>
    /// <exception cref="System.ArgumentOutOfRangeException">当密码的长度超过 128 个字符时抛出该异常。</exception>
    public User(string username, string password)
    {
        if(username == null || username == "" || password == null || password == "")
        {
            throw new ArgumentNullException("Username and password cannot be empty.");
        }

        if (username.Length > 128)
        {
            throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
        }

        if (password.Length > 128)
        {
            throw new ArgumentOutOfRangeException("The length of password must not exceed 128 characters.");
        }

        // Initialization
        _Username = username;
        _Password = password;
    }


    /// <summary>
    /// 获取或设置用户名。
    /// </summary>
    /// <exception cref="System.ArgumentNullException">当用户名为空时抛出该异常。</exception>
    /// <exception cref="System.ArgumentOutOfRangeException">当用户名的长度超过 128 个字符时抛出该异常。</exception>
    public string Username
    {
        get { return _Username; }
        set
        {
            if (value == null || value == "")
            {
                throw new ArgumentNullException("Username cannot be empty.");
            }

            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
            }

            // Set username
            _Username = value;
        }
    }

    /// <summary>
    /// 获取或设置密码。
    /// </summary>
    /// <exception cref="System.ArgumentNullException">当密码为空时抛出该异常。</exception>
    /// <exception cref="System.ArgumentOutOfRangeException">当密码的长度超过 128 个字符时抛出该异常。</exception>
    public string Password
    {
        get { return _Password; }
        set
        {
            if (value == null || value == "")
            {
                throw new ArgumentNullException("Password cannot be empty.");
            }

            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of password must not exceed 128 characters.");
            }

            // Set password
            _Password = value;
        }
    }
}


/// <summary>
/// 表示用户的注册信息实体。
/// </summary>
public class RegistrationInfo
{
    private string _Username; // NOT NULL
    private string _RegistrationEmail;
    private string _PasswordQuestion;
    private string _PasswordAnswer;


    public RegistrationInfo(string username)
    {
        if (username == null || username == "")
        {
            throw new ArgumentNullException("Username cannot be empty.");
        }

        if (username.Length > 128)
        {
            throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
        }

        // Initialization
        _Username = username;
    }


    public string Username
    {
        get { return _Username; }
        set
        {
            if (value == null || value == "")
            {
                throw new ArgumentNullException("Username cannot be empty.");
            }

            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
            }

            _Username = value;
        }
    }

    public string RegistrationEmail
    {
        get { return _RegistrationEmail; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of registration email must not exceed 128 characters.");
            }

            _RegistrationEmail = value;
        }
    }

    public string PasswordQuestion
    {
        get { return _PasswordQuestion; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of password question must not exceed 128 characters.");
            }

            _PasswordQuestion = value;
        }
    }

    public string PasswordAnswer
    {
        get { return _PasswordAnswer; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of password answer must not exceed 128 characters.");
            }

            _PasswordAnswer = value;
        }
    }
}


/// <summary>
/// 表示用户的个人信息。
/// </summary>
public class PersonalInfo
{
    private string _Username; // NOT NULL
    private string _Nickname;
    private string _RealName;
    private DateTime _Birthday;
    private string _IdentityCardNumber;


    public PersonalInfo(string username)
    {
        if (username == null || username == "")
        {
            throw new ArgumentNullException("Username cannot be empty.");
        }

        if (username.Length > 128)
        {
            throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
        }

        // Initialization
        _Username = username;
    }


    public string Username
    {
        get { return _Username; }
        set
        {
            if (value == null || value == "")
            {
                throw new ArgumentNullException("Username cannot be empty.");
            }

            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
            }

            _Username = value;
        }
    }

    public string Nickname
    {
        get { return _Nickname; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of nickname must not exceed 128 characters.");
            }

            _Nickname = value;
        }
    }

    public string RealName
    {
        get { return _RealName; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of real name must not exceed 128 characters.");
            }

            _RealName = value;
        }
    }

    public DateTime Birthday
    {
        get { return _Birthday; }
        set { _Birthday = value; }
    }

    public string IdentityCardNumber
    {
        get { return _IdentityCardNumber; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of identity card number must not exceed 128 characters.");
            }

            _IdentityCardNumber = value;
        }
    }
}


/// <summary>
/// 表示用户的联系信息。
/// </summary>
public class ContactInfo
{
    private string _Username; // NOT NULL
    private string _ContactEmail;
    private string _PhoneNumber;
    private string _QQNumber;
    private string _PersonalWebsiteURL;
    private string _SinaWeiboURL;
    private string _RenrenURL;
    private string _FacebookURL;
    private string _TwitterURL;


    public ContactInfo(string username)
    {
        if (username == null || username == "")
        {
            throw new ArgumentNullException("Username cannot be empty.");
        }

        if (username.Length > 128)
        {
            throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
        }

        // Initialization
        _Username = username;
    }


    public string Username
    {
        get { return _Username; }
        set
        {
            if (value == null || value == "")
            {
                throw new ArgumentNullException("Username cannot be empty.");
            }

            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
            }

            _Username = value;
        }
    }

    public string ContactEmail
    {
        get { return _ContactEmail; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of contact email must not exceed 128 characters.");
            }

            _ContactEmail = value;
        }
    }

    public string PhoneNumber
    {
        get { return _PhoneNumber; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of phone number must not exceed 128 characters.");
            }

            _PhoneNumber = value;
        }
    }

    public string QQNumber
    {
        get { return _QQNumber; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of QQ number must not exceed 128 characters.");
            }

            _QQNumber = value;
        }
    }

    public string PersonalWebsiteURL
    {
        get { return _PersonalWebsiteURL; }
        set
        {
            if (value.Length > 256)
            {
                throw new ArgumentOutOfRangeException("The length of URL must not exceed 256 characters.");
            }

            _PersonalWebsiteURL = value;
        }
    }

    public string SinaWeiboURL
    {
        get { return _SinaWeiboURL; }
        set
        {
            if (value.Length > 256)
            {
                throw new ArgumentOutOfRangeException("The length of URL must not exceed 256 characters.");
            }

            _SinaWeiboURL = value;
        }
    }

    public string RenrenURL
    {
        get { return _RenrenURL; }
        set
        {
            if (value.Length > 256)
            {
                throw new ArgumentOutOfRangeException("The length of URL must not exceed 256 characters.");
            }

            _RenrenURL = value;
        }
    }

    public string FacebookURL
    {
        get { return _FacebookURL; }
        set
        {
            if (value.Length > 256)
            {
                throw new ArgumentOutOfRangeException("The length of URL must not exceed 256 characters.");
            }

            _FacebookURL = value;
        }
    }

    public string TwitterURL
    {
        get { return _TwitterURL; }
        set
        {
            if (value.Length > 256)
            {
                throw new ArgumentOutOfRangeException("The length of URL must not exceed 256 characters.");
            }

            _TwitterURL = value;
        }
    }
}


/// <summary>
/// 表示学生信息。（经过认证的）
/// </summary>
public class Auth_Student
{
    private string _Username; // NOT NULL
    private string _StudentID; // NOT NULL


    public Auth_Student(string username, string studentID)
    {
        if (username == null || username == "" || studentID == null || studentID == "")
        {
            throw new ArgumentNullException("Username and student ID cannot be empty.");
        }

        if (username.Length > 128)
        {
            throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
        }

        if (studentID.Length > 128)
        {
            throw new ArgumentOutOfRangeException("The length of student ID must not exceed 128 characters.");
        }

        // Initialization
        _Username = username;
        _StudentID = studentID;
    }


    public string Username
    {
        get { return _Username; }
        set
        {
            if (value == null || value == "")
            {
                throw new ArgumentNullException("Username cannot be empty.");
            }

            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
            }

            _Username = value;
        }
    }

    public string StudentID
    {
        get { return _StudentID; }
        set
        {
            if (value == null || value == "")
            {
                throw new ArgumentNullException("Student ID cannot be empty.");
            }

            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of student ID must not exceed 128 characters.");
            }

            _StudentID = value;
        }
    }
}


/// <summary>
/// 表示学生的个人信息。（经过认证的）
/// </summary>
public class Auth_PersonalInfo
{
    private string _Username; // NOT NULL
    private string _Name;
    private string _FormerName;
    private string _DepartmentID;
    private string _DepartmentName;
    private string _MajorID;
    private string _MajorName;
    private string _Grade;
    private DateTime _EntryDate;


    public Auth_PersonalInfo(string username)
    {
        if (username == null || username == "")
        {
            throw new ArgumentNullException("Username cannot be empty.");
        }

        if (username.Length > 128)
        {
            throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
        }

        // Initialization
        _Username = username;
    }


    public string Username
    {
        get { return _Username; }
        set
        {
            if (value == null || value == "")
            {
                throw new ArgumentNullException("Username cannot be empty.");
            }

            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of username must not exceed 128 characters.");
            }

            _Username = value;
        }
    }

    public string Name
    {
        get { return _Name; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of name of student must not exceed 128 characters.");
            }

            _Name = value;
        }
    }

    public string FormerName
    {
        get { return _FormerName; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of former name must not exceed 128 characters.");
            }

            _FormerName = value;
        }
    }

    public string DepartmentID
    {
        get { return _DepartmentID; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of department ID must not exceed 128 characters.");
            }

            _DepartmentID = value;
        }
    }

    public string DepartmentName
    {
        get { return _DepartmentName; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of department name must not exceed 128 characters.");
            }

            _DepartmentName = value;
        }
    }

    public string MajorID
    {
        get { return _MajorID; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of major ID must not exceed 128 characters.");
            }

            _MajorID = value;
        }
    }

    public string MajorName
    {
        get { return _MajorName; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of major name must not exceed 128 characters.");
            }

            _MajorName = value;
        }
    }

    public string Grade
    {
        get { return _Grade; }
        set
        {
            if (value.Length > 128)
            {
                throw new ArgumentOutOfRangeException("The length of grade must not exceed 128 characters.");
            }

            _Grade = value;
        }
    }

    public DateTime EntryDate
    {
        get { return _EntryDate; }
        set { _EntryDate = value; }
    }
}
